<template>
  <div>
    <div class="flex justify-between">
      <p class="text-lg">提款请求</p>
      <a-button type="primary" @click="submit">确定</a-button>
    </div>
    <a-table rowKey="projectNum" :columns="columns" :data-source="selectedRows">
      <span slot="date" slot-scope="date"> {{ humanizeDate(date) }}</span>
      <span slot="calcDate" slot-scope="calcDate"> {{ humanizeDate(calcDate) }}</span>
    </a-table>
  </div>
</template>
<script>
import moment from 'moment'
import { createMoneyarrange } from '@/api/common'
export default {
  name: 'lastStep',
  props: ['selectedRows', 'form'],
  data() {
    return {
      columns: [
        {
          title: '编号',
          dataIndex: 'projectNum',
          key: 'projectNum'
        },
        {
          title: '客户',
          dataIndex: 'clientName',
          key: 'clientName'
        },
        {
          title: '项目名称',
          dataIndex: 'addr',
          key: 'addr'
        },
        {
          title: '阶段',
          dataIndex: 'stage',
          key: 'stage'
        },
        {
          title: '律师',
          dataIndex: 'lawyerName',
          key: 'lawyerName'
        },
        {
          title: '提款日期',
          dataIndex: 'date',
          key: 'date',
          scopedSlots: { customRender: 'date' }
        },
        {
          title: '货币',
          dataIndex: 'currency',
          key: 'currency'
        },
        {
          title: '金额',
          dataIndex: 'amount',
          key: 'amount'
        }
      ],
      data: []
    }
  },
  methods: {
    humanizeDate(v) {
      if (v) {
        return moment(v * 1000).format('YYYY-MM-DD') || '--'
      } else {
        return '-'
      }
    },
    async submit() {
      const form = {
        withdrawIdList: this.selectedRows.map(el => el.id),
        ...this.form
      }
      createMoneyarrange(form)
      this.$router.back(-1)
    }
  }
}
</script>
<style lang="scss" scoped></style>
